package com.clear.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * 策略工厂
 */
public class OperationFactory {
    private static Map<String, Operation> operationMap = new HashMap<>();

    static {
        operationMap.put("+", new Addition());
        operationMap.put("-", new Subtraction());
        operationMap.put("*", new Multiplication());
    }

    public static Operation getOperation(String type) {
        if (type == null || type.isEmpty()) {
            throw new IllegalArgumentException("type should not be empty.");
        }
        return operationMap.get(type);
    }

}
